﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class RotateLetters : MonoBehaviour
{
    public RectTransform rectTsf;
    public GameObject rightNode;
    public Button btn;
    private Color normalColor = Color.gray;
    private Color rightColor = Color.black;
    public Text letterText;
    public Level4RotateLetters level4RotateLetters;
    public bool isRight;

    private void Start()
    {
        IsRight();
    }

    public void AddRotation(int dir)
    {
        btn.enabled = false;
        rectTsf.DOLocalRotate(rectTsf.rotation.eulerAngles + new Vector3(0, 0, 90 * dir), 0.5f).
            OnComplete(() =>
            {
                btn.enabled = true;
                IsRight();
            });

    }

    public bool IsRight()
    {
        isRight = false;
        if (rightNode.transform.position.y - this.transform.position.y > 0.1f)
        {
            isRight = true;
            level4RotateLetters.JudgeResult();
        }
        letterText.color = isRight ? rightColor : normalColor;
        return isRight;
    }
}
